/*
 * dc_motor_current_control.h
 *
 * Created:			05.08.2012 20:28:03
 * Author:			boecki91@gmail.com
 * Target:			atMEGA644P
 * URL:				$HeadURL: http://dc-motor-regelung.googlecode.com/svn/trunk/Software/dc_motor_current_control.h $
 * Last changed by:	$Author: boecki91@gmail.com $
 * Changed date:    $Date: 2012-08-05 20:21:36 +0000 (Sun, 05 Aug 2012) $
 * Last committed:  $Revision: 12 $
 *
 * ID:				$Id: dc_motor_current_control.h 12 2012-08-05 20:21:36Z boecki91@gmail.com $
 */
#ifndef DC_MOTOR_CURRENT_CONTROL_H_
#define DC_MOTOR_CURRENT_CONTROL_H_
//PWM Constants & Calculations
#define PWM_F 488
#define PWM_PRESCALE 1

//Motor Resistance, Inductivity and Voltage
#define MOTOR_R 11.7
#define MOTOR_L 0.004212
#define U_MAX	18.0


#define k_A 1/MOTOR_R
#define T_A MOTOR_L/MOTOR_R

//H-Bridge Calculations
#define k_SR U_MAX/1024.0 //10-Bit-Fullscale
#define T_SR 0.5/PWM_F

// Current-Messurement Constants
#define k_MC 1.0
#define T_MC 0.15915
// Current-Controller-Calculations
#define PWM_VALUE_0 250
#define PWM_PRESCALE_0 8
#define ABTAST_ZEIT F_CPU/PWM_PRESCALE_0/PWM_VALUE_0
#define T_AR ABTAST_ZEIT*T_A/10

extern volatile double soll;

extern void dc_motor_current_controll_init();
extern void dc_motor_current_controll_cycle();


#endif /* DC_MOTOR_CURRENT_CONTROL_H_ */